Hi guys, so in this lecture we are going to look at how to work out how many bombs surround a given square. This problem might be best solved by splitting it into two parts.
for example:
[[_,B,-,-],
[Y,-,-,-],
[B,B,X,-],
[B,-,-,B]]
In the above board, we want X to equal 1 because there are 2 bombs nearby. In the case of Y we want to return 3.
A few hints:
In [29]:
def test():
"""
Write your tests here...
Example:
>>> 1 + 1
2
"""
print("Testing Complete")
In [ ]:
def neighbour_squares(x, y, num_rows, num_cols):
"""
(x, y) 0-based index co-ordinate pair.
num_rows, num_cols: specifiy the max size of the board
returns all valid (x, y) coordinates from starting position.
"""
pass
def count_bombs(x, y, board):
"""
returns the number of neighbours of (x,y) that are bombs. Max is 8, min is 0.
"""
pass
test()